import axios from 'axios'
exports.getStudentNote = data => {
  const { classid, previewvideoid, from, size } = data
  return axios.get('/api/preview/studentnotes/byClasses', {
    params: {
      classid,
      previewvideoid,
      from,
      size
    }
  })
}
exports.getLessions = data => {
  const { teacherid, time, bookid, catelogid, timeOrder, from, size } = data
  return axios.get('/api/course/previewvideos/byteacher', {
    params: {
      teacherid,
      time,
      bookid,
      catelogid,
      timeOrder,
      from,
      size
    }
  })
}
exports.deleteLession = id => {
  return axios.delete(`/api/course/previewvideos/${id}`)
}
exports.putLession = data => {
  const { id, catalogId, isShare, name } = data
  return axios.put(`/api/course/previewvideos/${id}/updateCatelog`, {
    catalogId,
    isShare,
    name
  })
}
exports.postLession = data => {
  return axios({
    method: 'post',
    url: '/api/course/previewvideos/uploadOnlyVideo',
    data,
    headers: {
      'content-type': 'multipart/form-data'
    }
  })
}
exports.getBook = data => {
  const { id, term, from, size, subject } = data
  return axios.get('/api/course/books/byTeacher/' + id, {
    params: {
      termid: term,
      from,
      size,
      subjectid: subject
    }
  })
}
exports.getBrother = catelog => {
  return axios.get(`/api/course/bookcatelogs/${catelog}/brothers`)
}
exports.postBook = data => {
  const { bookId, isFolder, catalogName, parentId, sortIndex } = data
  return axios.post('/api/course/bookcatelogs', {
    bookId,
    isFolder,
    catalogName,
    parentId,
    sortIndex
  })
}
exports.putNode = data => {
  const {
    id,
    bookId,
    isFolder,
    catalogName,
    parentId,
    sortIndex,
    deleteFlag
  } = data
  return axios.put(`/api/course/bookcatelogs/${id}`, {
    bookId,
    isFolder,
    catalogName,
    parentId,
    sortIndex,
    deleteFlag
  })
}
exports.getClass = id => {
  return axios.get(`/api/course/teachers/${id}/classes`)
}
